# Contributor: Valery Kartel <valery.kartel@gmail.com>
# Contributor: Carlo Landmeter <clandmeter@alpinelinux.org>
# Maintainer: Carlo Landmeter <clandmeter@alpinelinux.org>
pkgname=lftp
pkgver=4.9.2
pkgrel=7
pkgdesc="Sophisticated ftp/http client"
url="https://lftp.tech"
arch="all"
license="GPL-3.0-or-later"
makedepends="zlib-dev openssl-dev>3 readline-dev ncurses-dev autoconf automake libtool gettext-dev"
subpackages="$pkgname-doc"
source="https://lftp.yar.ru/ftp/lftp-$pkgver.tar.xz
	gcc14.patch"

# secfixes:
#   4.8.4-r0:
#     - CVE-2018-10916

prepare() {
	default_prepare
	autoreconf -vif
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--with-openssl \
		--with-modules \
		--disable-nls \
		--disable-static \
		--enable-threads=posix
	make
}

package() {
	make -j1 install DESTDIR="$pkgdir"
	rm -f "$pkgdir"/usr/lib/charset.alias
	mkdir -p "$pkgdir"/usr/share/doc/$pkgname
	mv "$pkgdir"/usr/share/$pkgname "$pkgdir"/usr/share/doc/
}

check() {
	# skip ftp tests due to firewall issues
	make -C tests check check_PROGRAMS=
}

sha512sums="
cda8698e7e34d748715a6fe5dc06c758240302621c7957402f0cc67577acf1a96b436fda4282408dee8171dc84a31e0be432df99a30f0a10057a8e7ea9ec64ad  lftp-4.9.2.tar.xz
674df091879ee3f816ff0ac247d36d2244ecce85ac37b0be429bd8919260bb790ddc17c83e3aae2f481f7fd3a093606a231900f0d4d020f32ac0fcb576cc7ad1  gcc14.patch
"
